import { System } from "../../core/System";
import { ecs_trait_property, ecs_trait } from "../../core/Trait";
import { ECSkillManager } from "../components/ECSkillManager";

@ecs_trait()
class SkillCooldownTrait {
    @ecs_trait_property(ECSkillManager)
    skillManager!: ECSkillManager;
}

// 在ECS系统中更新
export class SkillCooldownSystem extends System {
    onStart(): void {
    }
    onUpdate(deltaTime: number): void {
        this.world.forEach(SkillCooldownTrait, (bundle) => {
            bundle.skillManager.skills.forEach(skill => {
                // 冷却
                skill.coolDown -= deltaTime;
                if (skill.coolDown <= 0) {
                    skill.coolDown = 0;
                }
            });
        });
    }
}